#define _CRT_SECURE_NO_WARNINGS 1
#include"SList.h"

void SListTest01()
{
	SLTNode* node1 = (SLTNode*)malloc(sizeof(SLTNode));
	node1->date = 1;
	SLTNode* node2 = (SLTNode*)malloc(sizeof(SLTNode));
	node2->date = 2;
	SLTNode* node3 = (SLTNode*)malloc(sizeof(SLTNode));
	node3->date = 3;
	SLTNode* node4 = (SLTNode*)malloc(sizeof(SLTNode));
	node4->date = 4;

	node1->next = node2;
	node2->next = node3;
	node3->next = node4;
	node4->next = NULL;

	SLTNode* plist = node1;
	SLTPrint(plist);
}

SListTest02()
{
	SLTNode* plist = NULL;
	SLTPushBack(&plist, 3);
	SLTPushBack(&plist, 4);

	SLTPushFront(&plist, 2);
	SLTPushFront(&plist, 1);

	SLTPrint(plist);

	SLTPopBack(&plist);
	SLTPrint(plist);

	SLTPopBack(&plist);
	SLTPrint(plist);

	SLTPopBack(&plist);
	SLTPrint(plist);

	SLTPopBack(&plist);
	SLTPrint(plist);
}

void SListTest03()
{
	SLTNode* plist = NULL;
	SLTPushBack(&plist, 3);
	SLTPushBack(&plist, 4);

	SLTPushFront(&plist, 2);
	SLTPushFront(&plist, 1);

	SLTPopFront(&plist);
	SLTPrint(plist);

	SLTPopFront(&plist);
	SLTPrint(plist);

	SLTPopFront(&plist);
	SLTPrint(plist);

	SLTPopFront(&plist);
	SLTPrint(plist);
}

SListTest04()
{
	SLTNode* plist = NULL;
	SLTPushBack(&plist, 3);
	SLTPushBack(&plist, 4);

	SLTPushFront(&plist, 2);
	SLTPushFront(&plist, 1);

	SLTNode* tmp = SLTFind(&plist, 3);
	if (tmp != NULL)
		printf("yes\n");
	else
		printf("no!\n");

	SLTInsert(&plist, tmp, 100);
	SLTPrint(plist);

	SLTInsertAfter(tmp, 20);
	SLTPrint(plist);

	SLTEraseAfter(tmp);
	SLTPrint(plist);

	SLTErase(&plist, plist);
	SLTPrint(plist);

	SLTDisTroy(&plist);
}

int main()
{

	//SListTest01( );

	//SListTest02();

	//SListTest03();

	SListTest04();


	return 0;
}